home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel 68k / lib_test / test_clone.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  1.8 KB  |  95 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_CLONE
  5.    
  6. inherit 
  7.    ANY
  8.       redefine
  9.      copy, is_equal
  10.       end;
  11.    
  12. creation make
  13.    
  14. feature 
  15.    
  16.    s1, s2: STRING;
  17.    a1, a2: ANIMAL;
  18.    
  19.    ai1, ai2: ARRAY[INTEGER];
  20.    
  21.    p1, p2: POINT;
  22.    t1, t2: TRIANGLE;
  23.    
  24.    make is
  25.       local
  26.      test_clone: like Current;
  27.       do
  28.      s1 := "foo";
  29.      s2 := clone(s1);
  30.      is_true(s1 /= s2);
  31.      is_true(equal(s1,s2));
  32.      is_true(s2.capacity >= s2.count);
  33.      s1.put('b',2);
  34.      is_true(not equal(s1,s2));
  35.      
  36.      !CAT!a1;
  37.      a2 := clone(a1);
  38.      is_true(a1 /= a2);
  39.      is_true(equal(a1,a2));
  40.      
  41.      ai1 := <<1,2,3>>;
  42.      ai2 := clone(ai1);
  43.      is_true(equal(ai1,ai2));
  44.      is_true(ai1 /= ai2);
  45.      
  46.      !!p1.make(1,2);
  47.      p2 := clone(p1);
  48.      is_true(p1 /= p2);
  49.      is_true(p1.x = p2.x);
  50.      is_true(p1.y = p2.y);
  51.      is_true(p1.same_type(p2));
  52.      
  53.      !!t1.make(p1,p2,p2);
  54.      t2 := clone(t1);
  55.      is_true(t1 /= t2);
  56.      is_true(t1.same_type(t2));
  57.      is_true(t1.p1 = t2.p1);
  58.      is_true(t1.p2 = t2.p2);
  59.      is_true(t1.p3 = t2.p3);
  60.      is_true(t2.p2 = t2.p3);
  61.      
  62.      test_clone := clone(Current);
  63.      is_true(test_clone.same_type(Current));
  64.      is_true(test_clone.s1 = Void);
  65.      is_true(test_clone.s2 = Void);
  66.      is_true(test_clone.ai1 = Void);
  67.      is_true(test_clone.t1 = Void);
  68.      is_true(test_clone.t2 = Void);
  69.       end;
  70.    
  71.    copy(other: like Current) is
  72.       do
  73.       end;
  74.    
  75.    is_equal(other: like Current): BOOLEAN is
  76.       do
  77.      Result := true;
  78.       end;
  79.    
  80.    is_true(b: BOOLEAN) is
  81.       do
  82.      cpt := cpt + 1;
  83.      if not b then
  84.         std_output.put_string("TEST_CLONE: ERROR Test # ");
  85.         std_output.put_integer(cpt);
  86.         std_output.put_string("%N");
  87.      else
  88.         -- std_output.put_string("Yes %N");
  89.      end;
  90.       end;
  91.    
  92.    cpt: INTEGER;
  93.    
  94. end -- TEST_CLONE
  95.